package com.emm.yixun.jobs;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.emm.yixun.common.response.Response;
import com.emm.yixun.system.service.NoticeTemporaryServiceFacade;

@Component
public class NoticeTemporaryJob {
	private static Logger logger = LoggerFactory.getLogger(NoticeTemporaryJob.class);
	@Autowired
	private NoticeTemporaryServiceFacade noticeTemporaryServiceFacade;

	private static Boolean FLAG = true;

	@Scheduled(cron = "${quartz.cron.noticeTemporaryJob}")
	public void autoSendMessage() {
		logger.info("NoticeTemporaryJob start..........");
		if (FLAG) {
			FLAG = false;
			Response<Boolean> response = noticeTemporaryServiceFacade.selectNoticeTemporary();
			if (!response.isSuccess()) {
				logger.error("消息发送失败");
			} else {
				logger.info("消息发送成功..........");
			}
			FLAG = true;
		}
		logger.info("NoticeTemporaryJob end..........");
	}

}
